<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>DHTML Tree samples. dhtmlXTree Pro - Storing state in Cookies</title>
</head>
<style>
	body {font-size:12px; }
	.{font-family:arial;font-size:12px}
	h1 {cursor:hand;font-size:16px;margin-left:10px;line-height:10px}
	xmp {color:green;font-size:12px;margin:0px;font-family:courier;background-color:#e6e6fa;padding:2px}
</style>
<body>
	<h1>Storing state in Cookies</h1>
	<link rel="STYLESHEET" type="text/css" href="../css/dhtmlXTree.css">
	<script  src="../js/dhtmlXCommon.js"></script>
	<script  src="../js/dhtmlXTree.js"></script>
	<script  src="../js/dhtmlXTree_xw.js"></script>
	Open state saved to cookies, so you can save state, refresh page and restore previous state after that</br>
    Tree can be serialized to XML, level of data serialization can be defined by related checkboxes.
	<table>
		<tr>
			<td>
				<div id="treeboxbox_tree" style="width:260; height:260;background-color:#f5f5f5;border :1px solid Silver;; overflow:auto;"/>
			</td>
			<td valign="top">
			<a href="javascript:void(0)" onclick="tree.saveOpenStates()">Save open state</a><br>
			<a href="javascript:void(0)" onclick="tree.loadOpenStates()">Restore open state</a><br>
			<a href="javascript:void(0)" onclick="tree.setSerializationLevel(document.getElementById('sm1').checked,document.getElementById('sm2').checked);  document.getElementById('zet1').value=tree.serializeTree()">Get tree XML</a> <input id="sm1" type="checkbox"><label for="sm1">User Data</label>&nbsp;&nbsp;<input id="sm2" type="checkbox"><label for="sm2">Details</label><br>
			<textarea id="zet1" style="width:300; height:200;"></textarea>
			</td>
		</tr>
		<tr>
			<td></td>
		</tr>
	</table>
<hr>
<XMP>
<div id="treeboxbox_tree" style="width:200;height:200"></div>
<script>
	tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
		tree.setImagePath("../imgs/");
		tree.loadXML("tree.xml")
		
		...
		//save open state
		tree.saveOpenStates()
		//load open state
		tree.loadOpenStates()
		//get tree xml
		var xml=tree.serializeTree()
</script>
</XMP>
	<script>

			tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
			tree.setImagePath("../imgs/");
			tree.enableDragAndDrop(true);			
			tree.loadXML("tree.xml",function(){tree.loadOpenStates()})
			
			
	</script>
<br><br>

</body>
</html>
